"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EcsSystem = void 0;
var EcsComponent_1 = require("./EcsComponent");
var EcsSystem = /** @class */ (function () {
    /**
     *
     * @param world 世界
     * @param defaltGroupComps 系统默认组关心的组件类型
     */
    function EcsSystem(world, defaltGroupComps) {
        var _a;
        this._enable = true;
        this.defaultGroup = null;
        this.updateCount = 0;
        this._world = world;
        if (defaltGroupComps.length >= 0) {
            this.defaultGroup = (_a = world).getGroupByCompIds.apply(_a, defaltGroupComps.map(function (i) { return EcsComponent_1.EcsComponent.getIdFromClz(i); }));
        }
    }
    Object.defineProperty(EcsSystem.prototype, "world", {
        get: function () {
            return this._world;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(EcsSystem.prototype, "name", {
        get: function () {
            return "";
        },
        enumerable: false,
        configurable: true
    });
    // public SetupGroup(world:EntityWorld)
    // {
    // 	//获取缓存组
    // 	//this.group = world.getEntityGroup(CompType1,CompType2);
    // 	//this.group.add
    // }
    EcsSystem.prototype.updateSystem = function () {
        if (this._enable && this.world.enable) {
            if (this.updateCount == 0) {
                this.onFirstUpdate();
            }
            this.update();
            this.updateCount++;
        }
    };
    EcsSystem.prototype.destroy = function (world) {
    };
    EcsSystem.prototype.isEnable = function () {
        return this._enable;
    };
    EcsSystem.prototype.setEnable = function (enable) {
        if (enable == this._enable) {
            return;
        }
        this._enable = enable;
        if (this._enable) {
            this.onEnable();
        }
        else {
            this.onDisable();
        }
    };
    EcsSystem.prototype.onFirstUpdate = function () {
    };
    EcsSystem.prototype.onEnable = function () {
    };
    EcsSystem.prototype.onDisable = function () {
    };
    return EcsSystem;
}());
exports.EcsSystem = EcsSystem;
